package com.example.back.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Jm
 * @date 2024/7/12
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result
{
    public static final String CODE_SUCCESS = "200";
    public static final String CODE_AUTH_ERROR = "401";
    public static final String CODE_SYS_ERROR = "500";

    private String code;
    private String msg;
    private Object data;

    public static Result success()
    {
        return new Result(CODE_SUCCESS, "请求成功", null);
    }

    public static Result success(Object data)
    {
        return new Result(CODE_SUCCESS, "请求成功", data);
    }

    public static Result error(String message)
    {
        return new Result(CODE_SUCCESS, message, null);
    }

    public static Result error(String code, String message)
    {
        return new Result(code, message, null);
    }

    public static Result error()
    {
        return new Result(CODE_SYS_ERROR, "系统错误", null);
    }
}
